<template>
  <view class="records-container">
    <!-- 只保留返回按钮 -->
    <view class="back-button" @click="goBack">
      <text class="back-icon">←</text>
    </view>
    
    <!-- 救援记录列表 -->
    <view class="records-list">
      <view class="record-item" v-for="(record, index) in rescueRecords" :key="index">
        <view class="record-header">
          <text class="record-time">{{ record.time }}</text>
        </view>
        <view class="record-info">
          <text class="record-location">{{ record.location }}</text>
        </view>
      </view>
      
      <!-- 加载更多指示器 -->
      <view class="load-more" v-if="hasMore">
        <text class="load-more-text">加载更多...</text>
      </view>
    </view>
  </view>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue';

// 救援记录数据
const rescueRecords = ref([
  {
    id: '1',
    time: '2022-10-10 11:09',
    location: '河南省焦作市山阳区32号',
    service: '搭电'
  },
  {
    id: '2',
    time: '2022-10-10 11:09',
    location: '河南省焦作市山阳区32号',
    service: '换胎'
  },
  {
    id: '3',
    time: '2022-10-10 11:09',
    location: '河南省焦作市山阳区32号',
    service: '拖车'
  },
  {
    id: '4',
    time: '2022-10-10 11:09',
    location: '洛阳市瀍河回族区36号',
    service: '搭电'
  },
  {
    id: '5',
    time: '2022-10-10 11:09',
    location: '洛阳市瀍河回族区36号',
    service: '换胎'
  },
  {
    id: '6',
    time: '2022-10-10 11:09',
    location: '洛阳市瀍河回族区36号',
    service: '拖车'
  },
  {
    id: '7',
    time: '2022-10-12 15:29',
    location: '洛阳市瀍河回族区36号',
    service: '搭电'
  },
  {
    id: '8',
    time: '2022-10-12 15:29',
    location: '洛阳市瀍河回族区36号',
    service: '换胎'
  },
  {
    id: '9',
    time: '2022-10-12 15:29',
    location: '洛阳市瀍河回族区36号',
    service: '拖车'
  }
]);

const hasMore = ref(false); // 是否有更多数据

// 返回上一页
const goBack = () => {
  uni.navigateBack();
};

// 页面加载时的操作
onMounted(() => {
  // 这里可以添加获取救援记录的API调用
  console.log('救援记录页面已加载');
});
</script>

<style scoped lang="scss">
.records-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: #f8f8f8;
}

/* 返回按钮 */
.back-button {
  position: fixed;
  top: 30rpx;
  left: 20rpx;
  width: 60rpx;
  height: 60rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  z-index: 100;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
}

.back-icon {
  font-size: 36rpx;
  color: #333;
}

/* 救援记录列表 */
.records-list {
  padding: 20rpx;
}

.record-item {
  background-color: white;
  border-radius: 12rpx;
  padding: 24rpx;
  margin-bottom: 20rpx;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}

.record-header {
  margin-bottom: 16rpx;
}

.record-time {
  font-size: 32rpx;
  color: #333;
  font-weight: bold;
}

.record-info {
  padding-top: 16rpx;
  border-top: 1rpx solid #eee;
}

.record-location {
  font-size: 28rpx;
  color: #666;
  line-height: 40rpx;
}

/* 加载更多指示器 */
.load-more {
  padding: 30rpx 0;
  text-align: center;
}

.load-more-text {
  font-size: 28rpx;
  color: #999;
}

/* 点击效果 */
.record-item:active {
  background-color: #f5f5f5;
}

.back-icon:active {
  color: #666;
}
</style>